<?php

/**
 * Class for rendering a meta tag element.
 *
 * @author Ian Clarence <ian.clarence@gmail.com>
 */
class ViewMeta extends ViewHtmlElement {

    /**
     * http-equiv values
     */
    const CONTENT_TYPE = "content-type";
    const CONTENT_STYLE_TYPE = "content-style-type";
    const EXPIRES = "expires";
    const SET_COOKIE = "set-cookie";

    /**
     * name values
     */
    const AUTHOR = "author";
    const DESCRIPTION = "description";
    const KEYWORDS = "keywords";
    const GENERATOR = "generator";
    const REVISED = "revised";

    /**
     * name values
     */
    const AUTHOR_NAME = "Ian Clarence <ian.clarence@gmail.com>";
    const CHAR_SET = "text/html;charset=";

    /**
     * The constructor.
     *
     * @param array $fields
     */
    public function __construct(array $fields = array()) {

        $fields["tag"] = "meta";
        $fields["name"] = isset($fields["name"]) ? $fields["name"] : self::AUTHOR;
        $fields["content"] = isset($fields["content"]) ? $fields["content"] : self::AUTHOR_NAME;
        
        parent::__construct($fields);

        if (isset($this->fields["http_equiv"])) {
            $this->setAttribute("http-equiv", $this->getHttpEquiv());
        }
        else {
            $this->setAttribute("name", $this->getName());
        }

        $this->setAttribute("content", $this->getContent());

        if (isset($this->fields["scheme"])) {
            $this->setAttribute("scheme", $this->getScheme());
        }
        
    }

}